﻿using System.Text;
using System.Web.Mvc;

namespace Mytrip.Helpers
{
    public static class CaptchaHelper
    {
        public static string CaptchaImage(this HtmlHelper helper, int width, int height, string fontfamily)
        {
            StringBuilder result = new StringBuilder();
            TagBuilder imgCaptcha = new TagBuilder("img");
            imgCaptcha.MergeAttribute("src", "/Content/images/empty.gif");
            imgCaptcha.MergeAttribute("alt", "Captcha");
            imgCaptcha.AddCssClass("captcha");
            imgCaptcha.MergeAttribute("style", "width: " + width + "px; height: " + height + "px; background-image:url('/Captcha/Image/" + width + "/" + height + "/" + fontfamily+"');");
            result.AppendLine(imgCaptcha.ToString());
            return result.ToString();
        }
    }
}